package com.dailyblue.java.project.user.controller;

import com.dailyblue.java.project.user.bean.Users;
import com.dailyblue.java.project.user.service.UsersService;
import com.dailyblue.java.project.user.util.JsonResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RequestMapping("/user")
@RestController
public class UsersController {
    @Resource
    private UsersService usersService;

    @GetMapping("/login")
    public JsonResult login(Users user) {
        return usersService.login(user);
    }

    @GetMapping("/is")
    public JsonResult is(HttpServletRequest request) {
        String token = request.getHeader("token");
        return usersService.isLogin(token);
    }

    @GetMapping("/userid/{token}")
    public JsonResult getUserId(@PathVariable("token") String token) {
        return usersService.getUserId(token);
    }
}
